package com.sp.scmdb.action;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import com.opensymphony.xwork2.ActionSupport;

public class DownloadAction extends ActionSupport {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String execute() throws Exception {
		return SUCCESS;  
	}

	public InputStream getDownloadFile() {
		 InputStream is = null;
		 try {
			 is = new FileInputStream(path + uploadName);
		} catch (Exception e) {
		}
		 return is;
	}
	
	private String fileName;
	private String path;
	private String uploadName;
	
	public String getFileName() {
		String name = "";  
		try {
			//name = new String(fileName.getBytes(), "ISO-8859-1");
			name = java.net.URLEncoder.encode(fileName, "UTF-8");
		} catch (Exception e) {
			e.printStackTrace();  
	    }
		
	    return name;
	}
	
	public void setFileName(String fileName) {
		try {
			this.fileName = new String(fileName.getBytes("ISO-8859-1"), "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();  
	    }
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getUploadName() {
		return uploadName;
	}

	public void setUploadName(String uploadName) {
		this.uploadName = uploadName;
	}
}
